﻿namespace Player.Controllers
{
    using System;
    using System.ComponentModel;
    using System.Threading;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    using Common.Interfaces;
    using Common.Protocol;

    using Player.Models;
    
    public class MainViewController: IController
    {
        public MainViewModel OpenFile()
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Multiselect = false;
            dlg.Filter = @"Protocol files (*.dat)|*.dat|All files (*.*)|*.*";
            DialogResult result = dlg.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    Reader.Close();
                }
                catch (Exception)
                {
                }

                Reader.Open(dlg.FileName);
            }

            return null;
        }
    }
}